<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Pay extends CI_Controller {

	public function __construct()
    {
        parent::__construct();
        $this->load->model('Order_model');
    }
	

	public function index()
	{
		$id = _get_key_val($this->input->get('id'),true);
		$o = $this->Order_model->get_info_by_id($id);
		if ($o['paystatus'] == 'payed')
		{
			redirect('m/order/detail?id='._get_key_val($o['id']));
		}
		$data['total_fee'] = $o['totalprice'];
		$this->Order_model->update_by_where(array('id'=>$id),$data);
		$o['total_fee'] = $o['totalprice'];
		$result = array(
			'o' => $o,
			);
		
		$this->load->view('m/pay',$result);
	}

	//支付定金
	public function earnest()
	{
		$id = _get_key_val($this->input->get('id'),true);
		$o = $this->Order_model->get_info_by_id($id);
		if ($o['paystatus'] == 'payed')
		{
			redirect('m/order/detail?id='._get_key_val($o['id']));
		}
		$data['total_fee'] = $this->config->item('earnest_fee');
		$this->Order_model->update_by_where(array('id'=>$id),$data);
		$o['total_fee'] = $data['total_fee'];
		$result = array(
				'o' => $o,
		);
		
		$this->load->view('m/pay',$result);
	}

}